package cn.com.bluemoon.daps.model.controller;

import cn.com.bluemoon.daps.common.datascope.BmPermission;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.model.entity.DapDataModelTableField;
import cn.com.bluemoon.daps.model.service.DapDataModelFieldRenameRecordService;
import com.google.common.annotations.VisibleForTesting;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/rename")
@Api(tags = {"字段重命名"})
public class DapDataModelRenameController {

    @Resource
    DapDataModelFieldRenameRecordService dapDataModelFieldRenameRecordService;

    @PostMapping("/insert")
    @ApiOperation("重命名记录")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "ok", response = Boolean.class)})
    @BmPermission(value = "model:register:list", name = "注册列表")
    @VisibleForTesting
    public ResultBean<Boolean> renameRecord(@RequestBody List<DapDataModelTableField> fieldList){

        dapDataModelFieldRenameRecordService.fieldIsRename(fieldList);
        return ResultBean.ok(true);

    }
}
